<?php
include_once('Admin.php');
if ($_POST['Action'] == 'UpDate') {
	$Rs = $db->SelectSQL("SELECT `PassWord` FROM `" . $dbprefix . "admin` WHERE `ID` = " . $_SESSION['ID']);
	if ($Rs[0][0] != md5($_POST['PassWord0'])) {MsgBox (1,'修改失败，您输入的旧密码不正确！','1');}
	$SQL = "UPDATE `" . $dbprefix . "admin` SET `PassWord` = '" . md5($_POST['PassWord']) . "' WHERE `ID` = " . $_SESSION['ID'];
	unset($Rs);
	if($db->ExecuteSQL($SQL)){
		AdminLog(1,1,'用户"' . $_SESSION['UserName'] . '"修改登录密码，结果：操作成功！');
		MsgBox (1,'密码修改成功，请记住新密码！','index.php?Action=Exit');
	} else {
		AdminLog(1,1,'用户"' . $_SESSION['UserName'] . '"修改登录密码，结果：操作失败！');
		MsgBox (1,'操作失败！','1');
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="./images/adminstyle.css" rel="stylesheet" type="text/css" />
<link rel="Shortcut Icon" href="../favicon.ico">
<link rel="Bookmark" href="../favicon.ico">
<script src="../js/csshovernotie6.js" type="text/javascript"></script>
<script type="text/javascript">
function nCheck() {
	if(document.form1.PassWord0.value.length<5){
		alert('请输入正确的旧密码。') ;
		document.form1.PassWord0.focus();
		return false;
	}	
	if(document.form1.PassWord.value.length<5){
		alert('新密码不得少于5个字符。') ;
		document.form1.PassWord.focus();
		return false;
	}
	if(document.form1.PassWord.value != document.form1.PassWord2.value){
		alert('您输入的新密码与确认密码不一致。') ;
		document.form1.PassWord2.focus();
		return false;
	}
}
</script>
</head>
<body>
<br />
<table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
  <form id="form1" name="form1" method="post" action="AdminPassWord.php" onSubmit="return nCheck()">
  <tr class="odd">
    <td colspan="3" align="center" class="Main_Title">修改密码</td>
  </tr>
  <tr class="odd">
    <td align="right">用 户 名：</td>
    <td><input type="text" disabled="disabled" class="input2" value="<?php echo $_SESSION['UserName']?>" readonly="true" /></td>
    <td><a href="AdminManage.php">修改管理员</a></td>
  </tr>
  <tr class="odd">
    <td align="right">旧 密 码： </td>
    <td><input name="PassWord0" type="password" class="input2" id="PassWord0" maxlength="20" />
      <span class="red">*</span></td>
    <td>&nbsp;</td>
  </tr>
  <tr class="odd">
    <td align="right">新 密 码：</td>
    <td><input name="PassWord" type="password" class="input2" id="PassWord" maxlength="32" />
      <span class="red">*</span></td>
    <td>5-20个字符组成</td>
  </tr>
  <tr class="odd">
    <td align="right">确认密码：</td>
    <td><input name="PassWord2" type="password" class="input2" id="PassWord2" maxlength="32" />
      <span class="red">*</span></td>
    <td>&nbsp;</td>
  </tr>
  <tr class="odd">
    <td><input name="Action" type="hidden" id="Action" value="UpDate" /></td>
    <td><input type="submit" name="button" id="button" value="提 交" class="submit" />
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input type="reset" name="button2" id="button2" value="重 置" class="submit" /></td>
    <td>&nbsp;</td>
  </tr>
</form>
</table>
</body>
</html>